package classes.multithread;

/**
 * @author : DuJiabao
 * @Date : 2021/2/9 9:39
 * @Project : java_learning
 * @File : null.java
 * @Desc :
 */
public class RunnableTest2 {
  public static void main(String[] args) {
    for (int i = 0; i < 5; i++) {
      new Thread(new RunnableImpl(), "thread"+i).start();
    }
  }
}

class RunnableImpl implements Runnable {
  public RunnableImpl() {
    System.out.println(Thread.currentThread().getName()+" constructed!");
  }

  @Override
  public void run() {
    for (int i = 0; i < 3; i++) {
      System.out.println(Thread.currentThread().getName() + " " + i);
      Thread.yield();
    }
  }
}
